package org.jeecg.modules.engineering.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.engineering.entity.EquipSort;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;

/**
 * @Description: 设备分类表
 * @Author: jeecg-boot
 * @Date:   2019-08-13
 * @Version: V1.0
 */
@Repository
public interface EquipSortMapper extends BaseMapper<EquipSort> {

    List<EquipSort> queryList();

    long selectCountByParentId(@Param("ids")List<String> ids, @Param("size")int size);

    @Select("select parent_ids from equip_sort where id = #{id}")
    String getParentIds(@Param("id") String id);

    @Update("UPDATE equip_sort SET parent_ids = REPLACE(parent_ids,#{parentIds},#{targetParentIds}) WHERE parent_ids like concat(#{whereParentIds},'%') ")
    void updateParentIds(@Param("parentIds") String parentIds, @Param("targetParentIds") String targetParentIds, @Param("whereParentIds") String whereParentIds);

    @Select("SELECT id from equip_sort WHERE parent_ids like CONCAT('%',#{id},'%') AND del_flag = 0")
    List<String> findChildList(@Param("id") String sortId);
}
